package com.xiaoshuidi.cloud.module.member.service.invite;

import com.xiaoshuidi.cloud.framework.web.core.util.WebFrameworkUtils;
import com.xiaoshuidi.cloud.module.member.controller.admin.invite.vo.InviteActivityConfigVo;
import com.xiaoshuidi.cloud.module.member.convert.invite.InviteActivityConvert;
import com.xiaoshuidi.cloud.module.member.pojo.invite.InviteActivityConfigEntity;
import com.xiaoshuidi.cloud.module.member.mapper.invite.InviteActivityConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;


/**
 * @description 邀请活动service层
 * @author Leo.Li
 * @date 2023-05-19 17:20:47
 * @version generator
 */
@Service
public class InviteActivityConfigService {

    @Autowired
    InviteActivityConfigMapper inviteActivityConfigMapper;

    public InviteActivityConfigVo getValidInviteConfig() {
        InviteActivityConfigEntity entity = inviteActivityConfigMapper.selectValidInviteConfig();
        if(entity != null){
            return InviteActivityConvert.INSTANCE.convert(entity);
        }else{
            return null;
        }
    }

    public void setInviteConfig(InviteActivityConfigVo form) {
        inviteActivityConfigMapper.updateValidConfig(WebFrameworkUtils.getLoginUserId());
        form.setId(null);
        InviteActivityConfigEntity entity = InviteActivityConvert.INSTANCE.convert(form);
        inviteActivityConfigMapper.insert(entity);
    }
}

